import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str;
        while (true) {
            System.out.println("请输入一个字符串");
            str = sc.next();
            boolean flag = checkStr(str);
            if (flag) {
                break;
            } else {
                System.out.println("当前字符串不符合规则,请重新你输入:");
                continue;
            }
        }
        StringBuilder sb = new StringBuilder();//字符串拼接
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            int number = c-48;//字符0到数字0相差48
            String s = changeLuoMa(number);
            sb.append(s);
        }
        System.out.println(sb);
    }
    public static String changeLuoMa(int number){
        //定义一个数组
        String[] arr = {"","I","II","III","IV","V","VI","VII","VIII","IX"};
        return arr[number];
    }
    public static boolean checkStr(String str){
        if(str.length()>=9){
            return false;
        }
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if(c<'0'||c>'9'){
                return false;
            }
        }
        return true;
    }
}